#include "FieldPlayer.h"
#include "Decision.h"
#include "Action.h"
#include "CommandSender.h"
#include "Strategy.h"

#include "States/FullState.h"

FieldPlayer::FieldPlayer()
{
    init();

    run();
}

void FieldPlayer::run()
{
    Move();

    mDecision = new Decision(0);
    mStrategy = new InterceptAndKick();
    mDecision->setStrategy(mStrategy);

    int lTimeS = 0;
    int cTimeS = 0;

    //timer!!
    while(1)
    {
        lTimeS = cTimeS;
        cTimeS = FullState::instance().getmTimeStep();

        if (cTimeS == lTimeS + 1)
        {
                Action* a = mDecision->nextAction();
                mCommandSender->sendActionT(*a);
        }
        else if (cTimeS != lTimeS)
        {
            printf("TimeStep skipped %d %d\n", lTimeS, cTimeS);
        }
        sleep(0.02);
    }
}
